package cn.com.cym.gamezao.web.recruit;

import cn.com.cym.gamezao.annotation.AuthToken;
import cn.com.cym.gamezao.base.BaseController;
import cn.com.cym.gamezao.base.BaseService;
import cn.com.cym.gamezao.entity.xmu.recruit.ApplyLog;
import cn.com.cym.gamezao.service.recruit.ApplyLogService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.lang.NonNull;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "r-岗位相关")
@RestController
@RequestMapping(value = "apply_log")
@AuthToken(rule = "recruit.applyLog")
public class ApplyLogController extends BaseController<ApplyLog> {

    final ApplyLogService thisService;

    ApplyLogController(ApplyLogService thisService){
        this.thisService = thisService;
    }

    @Override
    public BaseService<ApplyLog> getService() {
        return thisService;
    }


    @ApiImplicitParam(name = "id", value = "id", required = true,dataType = "Long")
    @ApiOperation(value = "按id获取")
    @ApiOperationSupport(order = 1, author = "mr.chen")
    @GetMapping("/apply/{applyId}")
    @AuthToken(rule = "search",require = false)
    public ResponseEntity<?> getById(@PathVariable @NonNull Long applyId) {
        final List<ApplyLog> ApplyLogs = this.thisService.getAllByUserApplyId(applyId);
        return ResponseEntity.ok(ApplyLogs);
    }



    @ApiImplicitParam(name = "applyLog", value = "applyLog", required = true,dataType = "ApplyLog")
    @ApiOperation(value = "审核")
    @ApiOperationSupport(order = 1, author = "mr.chen")
    @PostMapping("/apply")
    @AuthToken(rule = "save",require = false)
    public ResponseEntity<?> save(@RequestBody ApplyLog applyLog) {
        ApplyLog save = this.thisService.save(applyLog);
        return ResponseEntity.ok(save);
    }
}
